package com.winkyle.woodenfish.controller.activity;

import android.databinding.DataBindingUtil;
import android.os.Bundle;

import com.winkyle.woodenfish.R;
import com.winkyle.woodenfish.databinding.ActivityLoginBinding;
import com.winkyle.woodenfish.mvpview.LoginView;
import com.winkyle.woodenfish.factory.presenterfactory.CreatePresenter;
import com.winkyle.woodenfish.presenter.LoginPresenter;

/**
 * @author winkyle
 * @date 2018/06/13
 * @description 继承自 {@link AbstractMvpActivity}的活动类LoginActivity，app的登录页
 */
@CreatePresenter(value = LoginPresenter.class)
public class LoginActivity extends AbstractMvpActivity<LoginView, LoginPresenter> implements LoginView {
    private String TAG = "LoginActivity";

    private ActivityLoginBinding activityLoginBinding;

    /**
     * @description 活动创建，指定layout布局
     * @param savedInstanceState 保存的活动状态的数据
     * @return
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityLoginBinding = DataBindingUtil.setContentView(this, R.layout.activity_login);
        initActivity();
    }

    /**
     * @description 初始化活动的一些数据和动作
     * @return
     */
    public void initActivity() {
        activityLoginBinding.setLoginView(this);
    }

    /**
     * @description 调用p层登录功能
     * @return
     */
    @Override
    public void login() {
        getMvpPresenter().login(activityLoginBinding.account.getText().toString(), activityLoginBinding.password.getText().toString());
    }

    /**
     * @description 弹出提示成功Toast，结束本界面
     * @return
     */
    @Override
    public void loginSucceed() {
        showShortToast("登录成功");
        finish();
    }


    @Override
    public void toRegister() {
        //todo
        showRemindDialog("去注册功能敬请期待");
    }

    @Override
    public void qqLogin() {
        //todo
        showRemindDialog("qq登录功能敬请期待");
    }

    @Override
    public void weChatLogin() {
        //todo
        showRemindDialog("微信登录功能敬请期待");
    }

    @Override
    public void microBlogLogin() {
        //todo
        showRemindDialog("微博登录功能敬请期待");
    }

    @Override
    public void viewAgreement() {
        //todo
        startActivity(LoadUrlActivity.class,"url","http://blog.sina.com.cn/s/blog_67600b6e0102x76o.html");
    }

    @Override
    public void forgetPassword() {
        //todo
        showRemindDialog("忘记密码功能敬请期待");
    }

    /**
     * @description 结束本界面
     * @return
     */
    @Override
    public void close() {
        finish();
    }
}
